/*
 * DesktopPaneDelegate.h  0.4.0 / Dec 04, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef DESKTOPPANEDELEGATE_H
#define DESKTOPPANEDELEGATE_H

#include "Cute4jSwing.h"

#include "ContainerDelegate.h"

// DesktopPaneDelegate Class. --------------------------------------------------

/*!
 * \brief DesktopPane Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT DesktopPaneDelegate : public ContainerDelegate
{
  Q_OBJECT
protected:
  DesktopPaneDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void insertChild(JNIEnv *env, jlong childDelegate, jint index);
  void removeChild(JNIEnv *env, jlong childDelegate);
  void setCurrentComponent(JNIEnv *env, jlong componentDelegate);
  void selectNextComponent(JNIEnv *env);
  void selectPreviousComponent(JNIEnv *env);
  void closeCurrentComponent(JNIEnv *env);
  void closeAllComponents(JNIEnv *env);
  void cascadeComponents(JNIEnv *env);
  void tileComponents(JNIEnv *env);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void activeComponentChanged(jobject component);
public:
  virtual jobject getBackground(JNIEnv *env, jclass colorClass);
  virtual void setBackground(JNIEnv *env, jint argb);
  virtual void setNullBackground(JNIEnv *env);
public:
  inline QMdiArea *qMdiArea() const;
protected slots:
  void subWindowActivatedSlot(QMdiSubWindow *window);
private:
  static jmethodID sm_activeComponentChangedMID;
};

// DesktopPaneDelegate :: Public Inline Member Function. -----------------------

/*!
 * \brief Returns QMdiArea adaptee.
 *
 * \return QMdiArea adaptee
 */
inline QMdiArea *DesktopPaneDelegate::qMdiArea() const
{
  return static_cast<QMdiArea *>(qObject());
}

// Macro Definition. -----------------------------------------------------------

#define DESKTOP_PANE_DELEGATE \
    (reinterpret_cast<DesktopPaneDelegate *>(delegate))

#endif // DESKTOPPANEDELEGATE_H
